package com.bodu.exchange.controller;


import com.bodu.core.common.AbstractCommonController;
import com.bodu.core.entity.ParamReq;
import com.bodu.core.entity.result.PageResult;
import com.bodu.core.entity.result.Result;
import com.bodu.global.security.LoginUserUtil;
import com.bodu.global.annon.TraceLog;
import com.bodu.exchange.entity.vo.ExchangeIconVo;
import com.bodu.exchange.entity.request.ExchangeIconRequest;
import com.bodu.exchange.service.ExchangeIconService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
* 账单图标 API
* @author Administrator
*/
@Api(tags = "账单图标 API")
@RestController
@RequestMapping("/exchangeIcon")
public class ExchangeIconController extends AbstractCommonController<ExchangeIconService, ExchangeIconRequest, ExchangeIconVo> {

    @Autowired
    private ExchangeIconService exchangeIconService;

    @TraceLog()
    @GetMapping("{id}")
    public Result getModel(@PathVariable("id") Long id) {
        return super.getModel(exchangeIconService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存账单图标")
    public Result<Integer> save(@RequestBody ExchangeIconRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(exchangeIconService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新账单图标")
    public Result<Integer> update(@RequestBody ExchangeIconRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(exchangeIconService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("账单图标-查询")
    public Result<List<ExchangeIconVo>>listPage(@RequestBody ParamReq req) {
        return super.listPage(exchangeIconService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("账单图标-统计")
    public Result<Integer> countPage(@RequestBody ParamReq req) {
        return super.countPage(exchangeIconService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("账单图标-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<ExchangeIconRequest> req) {
        return super.page(exchangeIconService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除账单图标")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(exchangeIconService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除账单图标")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(List<Long> ids) {
        return super.batchDelete(exchangeIconService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
